<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="${basePath}">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="semantic/semantic.css" rel="stylesheet" type="text/css">
<link href="static/css/follow.css" rel="stylesheet" type="text/css">
<link href="static/css/teacher.css" rel="stylesheet" type="text/css">
<!-- jquery一定要在semantic之前导入 -->
<script src="static/js/jquery-1.12.4.js" type="text/javascript"></script>
<script src="semantic/semantic.js" type="text/javascript"></script>
<script type="text/javascript">
	function ajax(params) {

		var xmlhttp;
		//判断XMLHttpRequest是否存在
		if (window.XMLHttpRequest) {
			xmlhttp = new XMLHttpRequest();
		} else {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}

		//readystate监听事件
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				//输出响应的结果
				console.log("aaaa" + xmlhttp);
				if (params.callback) {
					params.callback(xmlhttp);
				}
			}
		};

		//取出method参数
		var method = params.method ? params.method : "GET";
		var asynch = params.asynch ? params.asynch : true;

		//打开一个连接
		xmlhttp.open(method, params.url, asynch);
		//判断是否POST请求
		if (method.toLowerCase() == 'post') {
			//post请求一定要设置这句话
			xmlhttp.setRequestHeader("Content-Type",
					"application/x-www-form-urlencoded");
		}

		//判断请求是否有参数
		if (params.params) {
			//params.params = {"userName":"张三"，"gender":"男"};
			//转换成userName=张三&gengder=男
			var p = [];
			for (key in params.params) {
				p.push(key + "=" + params.params[key]);
			}
			xmlhttp.send(p.join("&"));
		} else {
			xmlhttp.send(null);
		}
	}
function noread(){
	$('#read').modal('hide');
}
	//JQuery入口
	$(function() {
		var read_content = document.getElementById("read_content");
		var num = 0;
		$('.readcon')
				.on(
						'click',
						function() {
							var id = $(this).attr("value");
							$('#read').modal('show');
							ajax({
								url : "follow/readcon?id=" + id,
								method : "POST",
								callback : function(xmlhttp) {
									var data;
									if (window.JSON) {
										data = JSON.parse(xmlhttp.response);
									} else {
										data = eval("(" + xmlhttp.response + ")");
									}
									if (data) {
										read_content.innerText = data.followRead;
									}

								}
							});

							$('#arfimfollow')
									.on(
											'click',
											function() {
												$('#read').modal('hide');
												var txt = document
														.getElementById("read_content").value;
												location
														.replace("follow/readcon?followContent="
																+ txt
																+ "&id="
																+ id);
											});
						});
	});
</script>
</head>
<body>
	<div>
		<div class="gps">
			<a class="home" href="staff?method=forward">首页</a> <i
				class="right chevron icon divider"></i> <a href="follow/read">批阅管理</a>
		</div>
		<div id="findfollow">
			<div class="ui info message">
				<form>
					<div class="ui form">
						<div class="fields">
							<div class="field">
								<label>学员姓名</label> <input type="text" name="studentname"
									value="${param.studentname }">
							</div>
							<div class="field">
								<label>员工姓名</label> <input type="text" name="staffname"
									value="${param.staffname }">
							</div>
							<div class="field">
								<label>是否批阅</label> <select name="followread">
									<option selected="selected" value=""
										${param.followRead !=0&&param.followRead !=1?'selected':''}>请选择</option>
									<option value="1" ${param.followRead ==1?'selected':''}>已批阅</option>
									<option value="0" ${param.followRead == 0?'selected':''}>未批阅</option>
								</select>
							</div>
							<div class="field">
								<label>&nbsp;</label>
								<button class="ui submit button">
									<i class="search icon"></i> 检索
								</button>
							</div>

						</div>
					</div>
				</form>
			</div>
		</div>
		<div id="followcontent">
			<c:forEach items="${AllFollowPoList}" var="followPo">
				<div class="ui info message">
					<div class="header" id="followcont">
						跟进对象：<span>${ followPo.followStudentName}</span> 跟进人：<span>${ followPo.followStaffName}</span>
						方式：<span>${ followPo.followStyle}</span> 日期：<span>${ followPo.followTime}</span>
						批阅：<span>${ followPo.followRead}</span>
						<c:if test="${!empty followPo.followRead}">
						<div class="negative ui button readcon"
							value="${followPo.followId}">修改</div>
						</c:if>
						<c:if test="${empty followPo.followRead}">
					<div class="negative ui button readcon"
							value="${followPo.followId}">批阅</div>
						</c:if>
						
						</div>
					<br> 跟进内容：<span id="content">${ followPo.followContent}</span>
				</div>
				<br />
			</c:forEach>
		</div>
		<div class="ui right floated pagination menu" style=" margin-top: -10px; margin-bottom: 100px; margin-right: 20px;">
			<c:if test="${apageSum > 1 }">
				<div class="page" >
					<a
						<c:if test="${anowpage!=1}">href="follow/read?anowpage=1${queryString}"</c:if>
						class="${anowpage == 1?'disable':''}">首页</a> <a
						<c:if test="${anowpage!=1}">href="follow/read?anowpage=${anowpage-1}${queryString}"</c:if>
						class="${anowpage == 1?'disable':''}">上一页</a> <span>${anowpage}/${ apageSum}
					</span> <a
						<c:if test="${anowpage!=apageSum}">href="follow/read?anowpage=${anowpage+1}${queryString}"</c:if>
						class="${anowpage == apageSum?'disable':''}">下一页</a> <a
						<c:if test="${anowpage!=apageSum}">href="follow/read?anowpage=${apageSum }${queryString}"</c:if>
						class="${anowpage == apageSum?'disable':''}">最后一页</a>

				</div>
			</c:if>
		</div>

	</div>
	<div class="ui modal" id="read">
		<div class="header">批阅</div>
		<div class="teacher-content">
			<c:set var="test" value="newcoop"></c:set>
			<textarea id="read_content" rows="10" cols="80" style="margin-left: 50px;">
				</textarea>
				<div class= "actions">
			<div class="ui black deny button" onclick = "noread()">取消批阅</div>
			<button style="border-style: none;">
				<div class="ui positive right labeled icon button" id="arfimfollow">
					确认批阅 <i class="checkmark icon"></i>
				</div>
			</button>
			</div>
		</div>
	</div>
</body>
</html>